
package com.svse.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class CorsConfig implements WebMvcConfigurer {

    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                // 允许访问的客户端域名
                .allowedOrigins("*")
                // 是否允许请求带有验证信息
                .allowCredentials(true)
                //允许访问的方法名,GET POST等
                .allowedMethods("GET", "POST", "PUT", "DELETE", "OPTIONS")
                //连接时间
                .maxAge(3600);
    }
}